#include "ai.hh"

AI::AI (Vector3f* dir, Vector3f* speed, float speed_coef)
  : action_ (0),
    move_to_ (dir),
    speed_ (speed),
    speed_coef_ (speed_coef)
{
}

AI::~AI ()
{}

BasicAI::BasicAI (Vector3f* dir, Vector3f* speed, float speed_coef)
  : AI (dir, speed, speed_coef)
{}

BasicAI::~BasicAI ()
{}

void
BasicAI::move (const Vector3f& pos)
{
  Vector3f tmp = target_ - pos;

  // FIXME: Rethink this part, maybe one IA.
  if (tmp.get_norme () > 10)
    {
      *move_to_ = tmp / tmp.get_norme ();
      *speed_ = *move_to_ * speed_coef_;
      action_ = MOVE;
    }
}

void
BasicAI::act (const Vector3f& pos)
{
  Vector3f tmp = target_ - pos;

  if (tmp.get_norme () <= 10)
    {
      action_ = SHOOT;
    }
}
